{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "from bokeh.charts import Bar, output_notebook, show, defaults\n",
    "from bokeh.sampledata.autompg import autompg as df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "output_notebook()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Calculate some negative values to show handling of them"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "df['neg_mpg'] = 0 - df['mpg']"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Override some default values to avoid requiring input on each chart"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "defaults.width = 550\n",
    "defaults.height = 400"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Create and show each bar chart"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "bar_plot = Bar(df, label='cyl', title=\"label='cyl'\")\n",
    "show(bar_plot)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "bar_plot2 = Bar(df, label='cyl', bar_width=0.4, title=\"label='cyl' bar_width=0.4\")\n",
    "show(bar_plot2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "bar_plot3 = Bar(df, label='cyl', values='mpg', agg='mean',\n",
    "                title=\"label='cyl' values='mpg' agg='mean'\")\n",
    "show(bar_plot3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "bar_plot4 = Bar(df, label='cyl', title=\"label='cyl' color='DimGray'\", color='dimgray')\n",
    "show(bar_plot4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# multiple columns\n",
    "bar_plot5 = Bar(df, label=['cyl', 'origin'], values='mpg', agg='mean',\n",
    "                title=\"label=['cyl', 'origin'] values='mpg' agg='mean'\")\n",
    "show(bar_plot5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "bar_plot6 = Bar(df, label='origin', values='mpg', agg='mean', stack='cyl',\n",
    "                title=\"label='origin' values='mpg' agg='mean' stack='cyl'\", legend='top_right')\n",
    "show(bar_plot6)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "bar_plot7 = Bar(df, label='cyl', values='displ', agg='mean', group='origin',\n",
    "                title=\"label='cyl' values='displ' agg='mean' group='origin'\", legend='top_right')\n",
    "show(bar_plot7)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "bar_plot8 = Bar(df, label='cyl', values='neg_mpg', agg='mean', group='origin',\n",
    "                color='origin', legend='top_right',\n",
    "                title=\"label='cyl' values='neg_mpg' agg='mean' group='origin'\")\n",
    "show(bar_plot8)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.4.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
